using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;



namespace pardusshipcalc
{
    class Guns
    {
        public int gunReturnData { get; set; }

        #region GunData
            // Format: {damage, fire-rate, weight, cost, rank} a zero indicates N/A.
            // Lucidi Weapons have a unique ID because of their crystal requirement -
           public int[,] GunData  = {
                                 {0,0,0,0,0}, /* 0. :: None :: */
                                 {6,1,4,1000,0}, /* 1. 10MW Mining Laser */
                                 {15,1,6,5000,0}, /* 2. 30MW Mining Laser */
                                 {21,1,2,12000,0}, /* 3. 1MW Impulse Laser */
                                 {30,1,3,28000,0}, /*4. 5MW Impulse Laser */
                                 {27,2,4,86000,0}, /*5. 1MW Particle */
                                 {42,2,8,210000,0}, /*6. 4MW Particle */
                                 {42,2,5,510000,0}, /*7. 4MW LW Particle */
                                 {60,2,14,550000,0}, /*8. 20MW Particle */
                                 {60,2,10,925000,0}, /*9. 20MW LW Particle */
                                 {84,2,30,980000,0}, /*10. 100MW Particle */
                                 {84,2,24,2000000,0}, /*11. 100MW LW Particle */
                                 {30,3,22,180000,23}, /*12. 4MW Gatling */
                                 {30,3,14,540000,27}, /*13. 4MW LW Gatling */
                                 {48,3,34,400000,25}, /*14. 6MW Gatling */
                                 {48,3,20,1200000,29}, /*15. 6MW LW Gatling */
                                 {69,3,50,720000,28}, /*16. 10MW Gatling */
                                 {69,3,30,2160000,212}, /*17. 10MW LW Gatling */
                                 {115,3,78,2200000,213}, /*18. 20MW Gatling */
                                 {115,3,60,6600000,214}, /*19. 20MW LW Gatling */
                                 {240,1,38,2280000,212}, /*20. 35MW Plasma */
                                 {270,1,42,2500000,213}, /*21. 40MW Plasma */
                                 {345,1,54,8250000,214}, /*22. 60MW Plasma */
                                 {102,2,36,1400000,210}, /*23. 140MW Particle */
                                 {102,2,28,2400000,211}, /*24. 140MW LW Particle */
                                 {36,2,4,580000,6}, /* 25. Exoplasm */
                                 {42,2,8,400000,6}, /* 26. Endoplasm */
                                 {42,3,16,850000,6}, /* 27. Bio-Spore Array */
                                 {78,2,28,1680000,6}, /* 28. Viral Glands */
                                 {39,2,6,650000,7}, /* 29. 80MT MagDef */
                                 {51,2,7,950000,7}, /* 30. 120 MT MagDef */
                                 {165,1,30,1980000,7}, /* 31. LPC */
                                 {210,1,40,2600000,7}, /* 32. VLPC */
                                 {40,2,8,1,0}, /* 33. Lucidi Enforcer I */
                                 {55,2,14,2,0}, /* 34. Lucidi Enforcer II */
                                 {150,1,34,3,0}, /*  35. Lucidi Conqueror */
                                 {90,2,56,4,0} /* 36. Lucidi Plasma Thrower */
                               };
#endregion

           public int GetGunData(ref int mode, string gunText)
           {
               int[,] gunDataTemp = GunData;
               Guns infiniteRecursion = new Guns();
               
               switch (gunText)
               {
                   case ":: None ::":
                   case ":: Normal Guns::":
                   case ":: Empire Guns ::":
                   case "":
                   case " ":
                   case ":: Organic ::":
                   case ":: Electro-Magnetic ::":
                   case ":: Pardus ::":
                       infiniteRecursion.gunReturnData = gunDataTemp[0, mode];
                       return infiniteRecursion.gunReturnData;

                   case "10MW Mining Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[1, mode];
                       return infiniteRecursion.gunReturnData;

                   case "30MW Mining Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[2, mode];
                       return infiniteRecursion.gunReturnData;

                   case "1MW Impulse Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[3, mode];
                       return infiniteRecursion.gunReturnData;

                   case "5MW Impulse Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[4, mode];
                       return infiniteRecursion.gunReturnData;

                   case "1MW Particle Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[5, mode];
                       return infiniteRecursion.gunReturnData;

                   case "4MW Particle Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[6, mode];
                       return infiniteRecursion.gunReturnData;

                   case "4MW LW Particle Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[7, mode];
                       return infiniteRecursion.gunReturnData;

                   case "20MW Particle Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[8, mode];
                       return infiniteRecursion.gunReturnData;

                   case "20MW LW Particle Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[9, mode];
                       return infiniteRecursion.gunReturnData;

                   case "100MW Particle Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[10, mode];
                       return infiniteRecursion.gunReturnData;

                   case "100MW LW Particle Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[11, mode];
                       return infiniteRecursion.gunReturnData;

                   case "4MW Gatling Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[12, mode];
                       return infiniteRecursion.gunReturnData;

                   case "4MW LW Gatling Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[13, mode];
                       return infiniteRecursion.gunReturnData;

                   case "6MW Gatling Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[14, mode];
                       return infiniteRecursion.gunReturnData;

                   case "6MW LW Gatling Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[15, mode];
                       return infiniteRecursion.gunReturnData;

                   case "10MW Gatling Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[16, mode];
                       return infiniteRecursion.gunReturnData;

                   case "10MW LW Gatling Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[17, mode];
                       return infiniteRecursion.gunReturnData;

                   case "20MW Gatling Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[18, mode];
                       return infiniteRecursion.gunReturnData;

                   case "20MW LW Gatling Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[19, mode];
                       return infiniteRecursion.gunReturnData;

                   case "35MW Plasma":
                       infiniteRecursion.gunReturnData = gunDataTemp[20, mode];
                       return infiniteRecursion.gunReturnData;

                   case "40MW Plasma":
                       infiniteRecursion.gunReturnData = gunDataTemp[21, mode];
                       return infiniteRecursion.gunReturnData;

                   case "60MW Plasma":
                       infiniteRecursion.gunReturnData = gunDataTemp[22, mode];
                       return infiniteRecursion.gunReturnData;

                   case "140MW Particle Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[23, mode];
                       return infiniteRecursion.gunReturnData;

                   case "140MW LW Particle Laser":
                       infiniteRecursion.gunReturnData = gunDataTemp[24, mode];
                       return infiniteRecursion.gunReturnData;

                   case "Exoplasm Launcher":
                       infiniteRecursion.gunReturnData = gunDataTemp[25, mode];
                       return infiniteRecursion.gunReturnData;

                   case "Endoplasm Launcher":
                       infiniteRecursion.gunReturnData = gunDataTemp[26, mode];
                       return infiniteRecursion.gunReturnData;

                   case "Bio-Spore Array":
                       infiniteRecursion.gunReturnData = gunDataTemp[27, mode];
                       return infiniteRecursion.gunReturnData;

                   case "Viral Glands":
                       infiniteRecursion.gunReturnData = gunDataTemp[28, mode];
                       return infiniteRecursion.gunReturnData;

                   case "80MT Magnetic Defractor":
                       infiniteRecursion.gunReturnData = gunDataTemp[29, mode];
                       return infiniteRecursion.gunReturnData;

                   case "120MT Magnetic Defractor":
                       infiniteRecursion.gunReturnData = gunDataTemp[30, mode];
                       return infiniteRecursion.gunReturnData;

                   case "Large Pulse Cannon":
                       infiniteRecursion.gunReturnData = gunDataTemp[31, mode];
                       return infiniteRecursion.gunReturnData;

                   case "Very Large Pulse Cannon":
                       infiniteRecursion.gunReturnData = gunDataTemp[32, mode];
                       return infiniteRecursion.gunReturnData;

                   case "Lucidi Enforcer I":
                       infiniteRecursion.gunReturnData = gunDataTemp[33, mode];
                       return infiniteRecursion.gunReturnData;

                   case "Lucidi Enforcer II":
                       infiniteRecursion.gunReturnData = gunDataTemp[34, mode];
                       return infiniteRecursion.gunReturnData;

                   case "Lucidi Conqueror":
                       infiniteRecursion.gunReturnData = gunDataTemp[35, mode];
                       return infiniteRecursion.gunReturnData;

                   case "Lucidi Plasma Thrower":
                       infiniteRecursion.gunReturnData = gunDataTemp[36, mode];
                       return infiniteRecursion.gunReturnData;
               }
               return 0;
           }

           public int determineGunType(int gunNumber)
           {
               int type = -1;

               if ((gunNumber >= 0) && (gunNumber < 25))
               {
                   type = 0; // Conv
               }
               if ((gunNumber >= 25) && (gunNumber < 29))
               {
                   type = 1; // Org
               }
               if ((gunNumber >= 29) && (gunNumber < 33))
               {
                   type = 2; // EM
               }
               if ((gunNumber >= 33))
               {
                   type = 3; // Pardus
               }

               return type;
           }

           public double determineGunEfficiency(int gunType, bool customArmor, int armorType,ComboBox armorComboBox)
           {
               /*
Conventional
Organic
Electro-Magnetic
Pardus
Avg All
Avg OEM
Avg COEM
                * */
               int ArmorType;

               if (customArmor == false)
               {
                   ArmorType = armorComboBox.SelectedIndex;
               }
               else
               {
                   ArmorType = armorType;
               }

               double efficiency = 0;

               switch (ArmorType)
               {
                   case 0: // Enemy Armor is conv.
                       switch (gunType)
                       {
                           case 0: // My gun is conv
                               efficiency = 100;
                               break;

                           case 1: // my gun is org
                               efficiency = 100;
                               break;

                           case 2: // My gun is em
                               efficiency = 110;
                               break;

                           case 3: // My gun is pardus
                               efficiency = 100;
                               break;
                       }
                       break;


                   case 1: // Enemy armor is org.
                       switch (gunType)
                       {
                           case 0: // My gun is conv
                               efficiency = 60;
                               break;

                           case 1:
                               efficiency = 50;
                               break;

                           case 2:
                               efficiency = 125;
                               break;

                           case 3:
                               efficiency = 100;
                               break;
                       }
                       break;

                   case 2: // Enemy armor is EM.
                       switch (gunType)
                       {
                           case 0: // My gun is conv
                               efficiency = 60;
                               break;

                           case 1:
                               efficiency = 100;
                               break;

                           case 2:
                               efficiency = 50;
                               break;

                           case 3:
                               efficiency = 125;
                               break;
                       }
                       break;

                   case 3: // Enemy armor is Pardus
                       switch (gunType)
                       {
                           case 0: // My gun is conv
                               efficiency = 45;
                               break;

                           case 1:
                               efficiency = 55;
                               break;

                           case 2:
                               efficiency = 75;
                               break;

                           case 3:
                               efficiency = 100;
                               break;
                       }
                       break;

                   case 4: // AVG against all types.
                       switch (gunType)
                       {
                           case 0: // My gun is conv
                               efficiency = 66.25;
                               break;

                           case 1: // my gun is org
                               efficiency = 76.25;
                               break;

                           case 2: // My gun is em
                               efficiency = 90;
                               break;

                           case 3: // My gun is pardus
                               efficiency = 106.25;
                               break;
                       }
                       break;

                   case 5: // AVG vs Org & EM
                       {
                           switch (gunType)
                           {
                               case 0: // My gun is conv
                                   efficiency = 60;
                                   break;

                               case 1: // my gun is org
                                   efficiency = 75;
                                   break;

                               case 2: // My gun is em
                                   efficiency = 87.5;
                                   break;

                               case 3: // My gun is pardus
                                   efficiency = 112.5;
                                   break;
                           }
                       }
                       break;

                   case 6: // AVG Vs COEM
                       {
                           switch (gunType)
                           {
                               case 0: // My gun is conv
                                   efficiency = 73.3;
                                   break;

                               case 1: // my gun is org
                                   efficiency = 83.3;
                                   break;

                               case 2: // My gun is em
                                   efficiency = 95;
                                   break;

                               case 3: // My gun is pardus
                                   efficiency = 108.3;
                                   break;
                           }
                       }
                       break;

               }

               return efficiency;
           }

           public double determineGunAvgEfficiencyAgainstAllArmorTypes(int gunType)
           {               
               double avgEfficiency = 0;

               switch (gunType)
                       {
                           case 0: // My gun is conv
                               avgEfficiency = 66.25;
                               break;

                           case 1: // my gun is org
                               avgEfficiency = 76.25;
                               break;

                           case 2: // My gun is em
                               avgEfficiency = 90;
                               break;

                           case 3: // My gun is pardus
                               avgEfficiency = 106.25;
                               break;
                       }               

               return avgEfficiency;
           }

           public double determineGunAvgEfficiencyAgainstEOArmorTypes(int gunType)
           {
               double avgEfficiency = 0;

               switch (gunType)
               {
                   case 0: // My gun is conv
                       avgEfficiency = 60;
                       break;

                   case 1: // my gun is org
                       avgEfficiency = 75;
                       break;

                   case 2: // My gun is em
                       avgEfficiency = 87.5;
                       break;

                   case 3: // My gun is pardus
                       avgEfficiency = 112.5;
                       break;
               }

               return avgEfficiency;
           }

           public double determineGunAvgEfficiencyAgainstCEOArmorTypes(int gunType)
           {
               double avgEfficiency = 0;

               switch (gunType)
               {
                   case 0: // My gun is conv
                       avgEfficiency = 73.3;
                       break;

                   case 1: // my gun is org
                       avgEfficiency = 83.3;
                       break;

                   case 2: // My gun is em
                       avgEfficiency = 95;
                       break;

                   case 3: // My gun is pardus
                       avgEfficiency = 108.3;
                       break;
               }

               return avgEfficiency;
           }

           public bool DetectTypeConflicts(int[] type, int gunNumber)
           {
               bool conflict = false;
               int l;

               for (l = 0; l < 5; l++)
               {
                   if (l != gunNumber)
                   {
                       if (type[l] == 1)
                       {
                           if (type[gunNumber] == 2)
                           {
                               conflict = true;
                           }
                       }
                       if (type[l] == 2)
                       {
                           if (type[gunNumber] == 1)
                           {
                               conflict = true;
                           }
                       }
                   }
               }
               return conflict;
           }

           public int determineGunNunmber(string gunName)
           {
               int gunNumber = 0;

               switch (gunName)
               {
                   case "None": gunNumber = 0;break;

                   case "10MW Mining Laser": gunNumber = 1; break;

                   case "30MW Mining Laser": gunNumber = 2; break;

                   case "1MW Impulse Laser":  gunNumber = 3; break;

                   case "5MW Impulse Laser": gunNumber = 4; break;

                   case "1MW Particle Laser": gunNumber = 5; break;

                   case "4MW Particle Laser": gunNumber = 6;break;

                   case "4MW LW Particle Laser":gunNumber = 7;break;

                   case "20MW Particle Laser": gunNumber = 8; break;

                   case "20MW LW Particle Laser": gunNumber = 9; break;

                   case "100MW Particle Laser":gunNumber = 10; break;

                   case "100MW LW Particle Laser": gunNumber = 11; break;

                   case "4MW Gatling Laser": gunNumber = 12; break;

                   case "4MW LW Gatling Laser": gunNumber = 13; break;

                   case "6MW Gatling Laser": gunNumber = 14; break;

                   case "6MW LW Gatling Laser": gunNumber = 15; break;

                   case "10MW Gatling Laser": gunNumber = 16; break;

                   case "10MW LW Gatling Laser": gunNumber = 17; break;

                   case "20MW Gatling Laser": gunNumber = 18;break;

                   case "20MW LW Gatling Laser": gunNumber = 19; break;

                   case "35MW Plasma": gunNumber = 20; break;

                   case "40MW Plasma": gunNumber = 21; break;

                   case "60MW Plasma": gunNumber = 22; break;

                   case "140MW Particle Laser": gunNumber = 23; break;

                   case "140MW LW Particle Laser": gunNumber = 24; break;

                   case "Exoplasm Launcher": gunNumber = 25; break;

                   case "Endoplasm Launcher": gunNumber = 26; break;

                   case "Bio-Spore Array": gunNumber = 27; break;

                   case "Viral Glands": gunNumber = 28; break;

                   case "80MT Magnetic Defractor": gunNumber = 29; break;

                   case "120MT Magnetic Defractor": gunNumber = 30; break;

                   case "Large Pulse Cannon": gunNumber = 31; break;

                   case "Very Large Pulse Cannon": gunNumber = 32; break;

                   case "Lucidi Enforcer I": gunNumber = 33; break;

                   case "Lucidi Enforcer II": gunNumber = 34; break;

                   case "Lucidi Conqueror": gunNumber = 35; break;

                   case "Lucidi Plasma Thrower": gunNumber = 36; break;
               }
               return gunNumber;
           }

           public double determineGunDamageWithWeapSpec(double gunDamage, int gunType, int cWeapSpecLevel, int oWeapSpecLevel, int emWeapSpecLevel)
           {
            int k;


                if (gunType == 0)
                {
                    for (k = 0; k < 5; k++)
                    {
                        if (cWeapSpecLevel == k)
                        {
                            gunDamage = (gunDamage / 100) * (100 + (k * 5));
                        }
                    }
                }
                if (gunType == 1)
                {
                    for (k = 0; k < 5; k++)
                    {
                        if (oWeapSpecLevel == k)
                        {
                            gunDamage = (gunDamage / 100) * (100 + (k * 5));
                        }
                    }
                }     
                if (gunType == 2)
                {
                    for (k = 0; k < 5; k++)
                    {
                        if (emWeapSpecLevel == k)
                        {
                            gunDamage = (gunDamage / 100) * (100 + (k * 5));
                        }
                    }
                }
             
            Math.Floor(gunDamage);
            return gunDamage;
           }

           public string determineGunName(int gunNumber)
        {
            string gunName = "";

            switch (gunNumber)
            {
                case 0:
                    gunName = "None";
                    break;

                case 1:
                    gunName = "10MW Mining Laser";
                    break;

                case 2:
                    gunName = "30MW Mining Laser";
                    break;

                case 3:
                    gunName = "1MW Impulse Laser";
                    break;

                case 4:
                    gunName = "5MW Impulse Laser";
                    break;

                case 5:
                    gunName = "1MW Particle Laser";
                    break;

                case 6:
                    gunName = "4MW Particle Laser";
                    break;

                case 7:
                    gunName = "4MW LW Particle Laser";
                    break;

                case 8:
                    gunName = "20MW Particle Laser";
                    break;

                case 9:
                    gunName = "20MW LW Particle Laser";
                    break;

                case 10:
                    gunName = "100MW Particle Laser";
                    break;

                case 11:
                    gunName = "100MW LW Particle Laser";
                    break;

                case 12:
                    gunName = "4MW Gatling Laser";
                    break;

                case 13:
                    gunName = "4MW LW Gatling Laser";
                    break;

                case 14:
                    gunName = "6MW Gatling Laser";
                    break;

                case 15:
                    gunName = "6MW LW Gatling Laser";
                    break;

                case 16:
                    gunName = "10MW Gatling Laser";
                    break;

                case 17:
                    gunName = "10MW LW Gatling Laser";
                    break;

                case 18:
                    gunName = "20MW Gatling Laser";
                    break;

                case 19: gunName = "20MW LW Gatling Laser"; break;

                case 20: gunName = "35MW Plasma"; break;

                case 21: gunName = "40MW Plasma"; break;

                case 22: gunName = "60MW Plasma"; break;

                case 23: gunName = "140MW Particle Laser"; break;

                case 24: gunName = "140MW LW Particle Laser"; break;

                case 25: gunName = "Exoplasm Launcher"; break;

                case 26: gunName = "Endoplasm Launcher"; break;

                case 27: gunName = "Bio-Spore Array"; break;

                case 28: gunName = "Viral Glands"; break;

                case 29: gunName = "80MT Magnetic Defractor"; break;

                case 30: gunName = "120MT Magnetic Defractor"; break;

                case 31: gunName = "Large Pulse Cannon"; break;

                case 32: gunName = "Very Large Pulse Cannon"; break;

                case 33: gunName = "Lucidi Enforcer I"; break;

                case 34: gunName = "Lucidi Enforcer II"; break;

                case 35: gunName = "Lucidi Conqueror"; break;

                case 36: gunName = "Lucidi Plasma Thrower"; break;
            }
            return gunName;
        }

    }
}
